package com.li.pm.function;


import com.li.pm.MainActivity;
import com.li.pm.R;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class CommonMethod {

	private Context context;
	private static int NOTIFY_ID=1000;
	private NotificationManager mNotifyManager;
	public CommonMethod(Context c) {
		context = c;
		mNotifyManager = (NotificationManager) context
		.getSystemService(Context.NOTIFICATION_SERVICE);
	}


	public void openNotify() {
		// 打开通知
		// notification

		Notification n = new Notification();
		n.icon = R.drawable.ic_launcher;
		n.tickerText = context.getResources().getString(R.string.notify_going);
		n.when = System.currentTimeMillis();
		Intent intent = new Intent(context, MainActivity.class);
		PendingIntent pintent = PendingIntent
				.getActivity(context, 0, intent, 0);
		n.setLatestEventInfo(context, context.getResources().getString(R.string.notify_title), context.getResources().getString(R.string.notify_content), pintent);
		n.flags |= Notification.FLAG_ONGOING_EVENT;
		n.flags |= Notification.FLAG_NO_CLEAR;
		mNotifyManager.notify(NOTIFY_ID, n);
	}

	public void cancelNotify() {
		mNotifyManager.cancel(NOTIFY_ID);
	}
	
	
}
